package main.newViz;

import framework.Person;
import framework.PersonsFactory;
import impl.game.grid.dnd.ComponentDND;

import javax.swing.*;
import java.awt.*;

/**
 * Date: 19.05.2008
 * Time: 17:30:55
 *
 * @author Denis DIR Rozhnev
 */
class StrategiesPanel extends JPanel {
    private LeftPanel leftPanel;
    private DrawPanel drawPanel;
    private StrategyButton[] buttons;

    StrategiesPanel(Config config) {
        super(new BorderLayout());
        leftPanel = new LeftPanel();
        add(leftPanel, BorderLayout.WEST);
        drawPanel = new DrawPanel(config);
        add(drawPanel, BorderLayout.CENTER);
    }

    private class LeftPanel extends JPanel {
        private LeftPanel() {
            super(new GridLayout(15, 1, 5, 5));
            setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
            buttons = new StrategyButton[PersonsFactory.STRATEGIES_COUNT];
            for (int i = 0; i < buttons.length; i++) {
                Person str = PersonsFactory.getPerson(i);
                StrategyButton button = new StrategyButton(str.getClass().getSimpleName(), str.getClass().getName(), str.getShortName());
                add(button);
                buttons[i] = button;
            }

        }
    }

    public class StrategyButton extends ComponentDND {
        protected String className;

        public StrategyButton(String name, String className, String shortName) {
            super(name, shortName);
            this.className = className;
        }

        protected String getMyClassName() {
            return className;
        }
    }
}
